#include "comm.h"
//#include<stdio.h>
//#include<sys/types.h>
//#include<sys/stat.h>
//#include<fcntl.h>
//#include<unistd.h>
//
//#define FIFO_FILE "./myfifo" //打开同一个文件，用来通信

int main()
{
  int fd = open(FIFO_FILE, O_WRONLY);
  if(fd < 0)
  {
    perror("open error");
    return 1;
  }
  //if(fd >= 0){
    char buf[64];
    while(1)
    {
      printf("Please enter message# ");
      fflush(stdout);
      ssize_t s = read(0, buf, sizeof(buf)-1);//从标准输入读
      if(s > 0){
        buf[s - 1] = 0;
        ///write(fd, buf, s);//写到管道文件中，写s长度
        write(fd, buf, strlen(buf));//写到管道文件中，写s长度
      }
    }
   //}
   close(fd);
   return 0;
}
